<?php defined('BASEPATH') or exit('No direct script access allowed');

class Module_Widgets extends Module {

	public $version = '1.0';
	
	public function info()
	{
		return array(
			'name' => array(
				'sl' => 'VtiÄ�niki',
				'en' => 'Widgets',
				'es' => 'Widgets',
				'pt' => 'Widgets',
				'de' => 'Widgets',
				'nl' => 'Widgets',
				'fr' => 'Widgets',
				'zh' => 'å°�çµ„ä»¶',
				'it' => 'Widgets',
				'ru' => 'Ð’Ð¸Ð´Ð¶ÐµÑ‚Ñ‹',
				'ar' => 'Ø§Ù„ÙˆØ¯Ø¬Øª',
				'cs' => 'Widgety',
				'fi' => 'Widgetit',
				'lt' => 'Papildiniai'
			),
			'description' => array(
				'sl' => 'Urejanje manjÅ¡ih delov blokov strani ti. VtiÄ�niki (Widgets)',
				'en' => 'Manage small sections of self-contained logic in blocks or "Widgets".',
				'es' => 'Manejar pequeÃ±as secciones de lÃ³gica autocontenida en bloques o "Widgets"',
				'pt' => 'Gerenciar pequenas seÃ§Ãµes de conteÃºdos em bloco conhecidos como "Widgets".',
				'de' => 'Verwaltet kleine, eigentstÃ¤ndige Bereiche, genannt "Widgets".',
				'nl' => 'Beheer kleine onderdelen die zelfstandige logica bevatten, ofwel "Widgets".',
				'fr' => 'GÃ©rer des mini application ou "Widgets".',
				'zh' => 'å�¯å°‡å°�æ®µçš„ç¨‹å¼�ç¢¼é€�é�Žå°�çµ„ä»¶ä¾†ç®¡ç�†ã€‚å�³æ‰€è¬‚ "Widgets"ï¼Œæˆ–ç¨±ç‚ºå°�å·¥å…·ã€�éƒ¨ä»¶ã€‚',
				'it' => 'Gestisci piccole sezioni di logica a se stante in blocchi o "Widgets".',
				'ru' => 'Ð£Ð¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ðµ Ð½ÐµÐ±Ð¾Ð»ÑŒÑˆÐ¸Ð¼Ð¸, Ñ�Ð°Ð¼Ð¾Ñ�Ñ‚Ð¾Ñ�Ñ‚ÐµÐ»ÑŒÐ½Ñ‹Ð¼Ð¸ Ð±Ð»Ð¾ÐºÐ°Ð¼Ð¸.',
				'ar' => 'Ø¥Ø¯Ø§Ø±Ø© Ø£Ù‚Ø³Ø§Ù… ØµØºÙŠØ±Ø© Ù…Ù† Ø§Ù„Ø¨Ø±Ù…Ø¬ÙŠØ§Øª Ù�ÙŠ Ù…Ø³Ø§Ø­Ø§Øª Ø§Ù„Ù…ÙˆÙ‚Ø¹ Ø£Ùˆ Ù…Ø§ ÙŠÙ�Ø³Ù…Ù‘Ù‰ Ø¨Ø§Ù„Ù€"ÙˆÙ�Ø¯Ù’Ø¬Ù�ØªÙ’".',
				'cs' => 'Spravujte malÃ© funkÄ�nÃ­ Ä�Ã¡sti webu neboli "Widgety".',
				'fi' => 'Hallitse pieniÃ¤ osioita, jotka sisÃ¤ltÃ¤vÃ¤t erillisiÃ¤ lohkoja tai "WidgettejÃ¤".',
				'el' => 'Î”Î¹Î±Ï‡ÎµÎ¯Ï�Î¹ÏƒÎ· Î¼Î¹ÎºÏ�ÏŽÎ½ Ï„Î¼Î·Î¼Î¬Ï„Ï‰Î½ Î±Ï…Ï„ÏŒÎ½Î¿Î¼Î·Ï‚ Ï€Ï�Î¿Î³Ï�Î±Î¼Î¼Î±Ï„Î¹ÏƒÏ„Î¹ÎºÎ®Ï‚ Î»Î¿Î³Î¹ÎºÎ®Ï‚ ÏƒÎµ Ï€ÎµÎ´Î¯Î± Î® "Widgets".',
				'lt' => 'NedideliÅ³, savarankiÅ¡kÅ³ blokÅ³ valdymas.'
			),
			//'frontend' => FALSE,
			//'backend'  => TRUE,
			//'menu'	  => 'content'
			'frontend' => FALSE,
		    'backend' => TRUE,
		    'skip_xss' => TRUE,
		    'menu' => 'content'
		);
	}
	
	public function install()
	{
		$this->dbforge->drop_table('widget_areas');
		$this->dbforge->drop_table('widget_instances');
		$this->dbforge->drop_table('widgets');
		
		$widget_areas = "
			CREATE TABLE " . $this->db->dbprefix('widget_areas') . " (
			  `id` int(11) NOT NULL AUTO_INCREMENT,
			  `slug` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
			  `title` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
			  PRIMARY KEY (`id`),
			  UNIQUE KEY `unique_slug` (`slug`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
		";
		
		$widget_instances = "
			CREATE TABLE " . $this->db->dbprefix('widget_instances') . " (
			  `id` int(11) NOT NULL AUTO_INCREMENT,
			  `title` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
			  `widget_id` int(11) DEFAULT NULL,
			  `widget_area_id` int(11) DEFAULT NULL,
			  `options` text COLLATE utf8_unicode_ci NOT NULL,
			  `order` int(10) NOT NULL DEFAULT '0',
			  `created_on` int(11) NOT NULL DEFAULT '0',
			  `updated_on` int(11) NOT NULL DEFAULT '0',
			  PRIMARY KEY (`id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
		";
		
		$widgets = "
			CREATE TABLE " . $this->db->dbprefix('widgets') . " (
			  `id` int(11) NOT NULL AUTO_INCREMENT,
			  `slug` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
			  `title` text COLLATE utf8_unicode_ci NOT NULL,
			  `description` text COLLATE utf8_unicode_ci NOT NULL,
			  `author` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
			  `website` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
			  `version` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
			  `enabled` tinyint(1) NOT NULL DEFAULT '1',
			  `order` int(5) NOT NULL DEFAULT '0',
			  PRIMARY KEY (`id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
		";
		
		$default_data = "
			INSERT INTO " . $this->db->dbprefix('widget_areas') . " (slug, title) VALUES ('sidebar', 'Sidebar');
		";
		
		if($this->db->query($widget_areas) &&
		   $this->db->query($widget_instances) &&
		   $this->db->query($widgets) &&
		   $this->db->query($default_data))
		{
			return TRUE;
		}
	}

	public function uninstall()
	{
		//it's a core module, lets keep it around
		return FALSE;
	}

	public function upgrade($old_version)
	{
		// Your Upgrade Logic
		return TRUE;
	}
	
	public function help()
	{
		// Return a string containing help info
		// You could include a file and return it here.
		return "No documentation has been added for this module.";
	}
}
/* End of file details.php */
